package com.fortune.controller;

import com.fortune.base.BaseAPIExcution;
import com.fortune.dto.excution.ProductCategoryExcution;
import com.fortune.enums.ProductCategoryEnum;
import com.fortune.service.AuthorityService;
import com.fortune.vo.authority.AuthorityDVo;
import com.fortune.vo.authority.AuthorityMVo;
import com.fortune.vo.authority.AuthorityPVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(value = "authority", description = "权限", tags = {"权限管理"})
@RestController
@RequestMapping("authority")
public class AuthorityController {
    @Autowired
    private AuthorityService authorityService;


    @ApiOperation(value = "获取平台所有权限（树形结构）", nickname = "authorityPList", notes = "", tags={ "@石匡" })
    @GetMapping(value = "authorityPList",
            produces = { MediaType.APPLICATION_JSON_VALUE })
    public BaseAPIExcution<List<AuthorityPVo>> pList() {
        List<AuthorityPVo> authorityPVos = authorityService.getTreeAuthority();
        return new ProductCategoryExcution<List<AuthorityPVo>>(authorityPVos, ProductCategoryEnum.SUCCESS);
    }


    @ApiOperation(value = "获取厂商所有权限（树形结构）", nickname = "authorityMList", notes = "", tags={ "@石匡" })
    @GetMapping(value = "authorityMList",
            produces = { MediaType.APPLICATION_JSON_VALUE })
    public BaseAPIExcution<List<AuthorityMVo>> mList() {
        List<AuthorityMVo> authorityMVos = authorityService.getTreeMAuthority();
        return new ProductCategoryExcution<List<AuthorityMVo>>(authorityMVos, ProductCategoryEnum.SUCCESS);
    }


    @ApiOperation(value = "获取经销商所有权限（树形结构）", nickname = "authorityDList", notes = "", tags={ "@石匡" })
    @GetMapping(value = "authorityDList",
            produces = { MediaType.APPLICATION_JSON_VALUE })
    public BaseAPIExcution<List<AuthorityDVo>> dList() {
        List<AuthorityDVo> authorityDVos = authorityService.getTreeDAuthority();
        return new ProductCategoryExcution<List<AuthorityDVo>>(authorityDVos, ProductCategoryEnum.SUCCESS);
    }
}
